home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / pas_all.zip / TI173.ASC < prev    next >
Text File  |  1991-09-11  |  9KB  |  331 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Turbo Database Toolbox                 NUMBER  :  173
  9.   VERSION  :  1.01
  10.        OS  :  PC DOS
  11.      DATE  :  May 14, 1986                             PAGE  :  1/5
  12.  
  13.     TITLE  :  Files Open Increase
  14.  
  15.  
  16.  
  17.  
  18.   Written by :
  19.   Randy Forgaard CompuServe 70307,521
  20.   Many thanks to Bela Lubkin (CompuServe 76703,3015) for
  21.   masterminding this idea, and Kim Kokkonen (CompuServe 72457,2131)
  22.   for helping debug it. If you have any questions or comments
  23.   regarding the following changes, please feel free to contact
  24.   Randy Forgaard on the Borland SIG or via EasyPlex on CompuServe.
  25.  
  26.   Due to a limitation of DOS, Turbo Pascal version 3.0 only allows
  27.   up to 15 files at a time to be open. The following method allows
  28.   you to have up to 96 files open simultaneously under DOS 2.0 or
  29.   2.1, or 252 files open simultaneously under DOS 3.0 or greater.
  30.  
  31.   This file is for use with the Turbo Access portion of the MS-DOS
  32.   Turbo Database Toolbox, version 1.01 or greater, together with
  33.   MS-DOS or PC-DOS Turbo Pascal 3.01A. If you have 1.00 of Turbo
  34.   Database Toolbox contact Borland International for a handout that
  35.   will update the Turbo Database Toolbox to version 1.01.
  36.  
  37.   This technique is totally internal to the Toolbox. After making
  38.   the indicated Toolbox changes, you will not have to change the
  39.   source code of programs that use the Toolbox (except to add a
  40.   compiler directive and an include file as indicated below).
  41.  
  42.   The code below uses the routines in EXTEND.PAS (also included).
  43.   Your program can use EXTEND.PAS directly, in addition to the
  44.   changes mentioned below for the Toolbox. The 96 (or 252) limit of
  45.   simultaneously open files will apply to the total of all Toolbox
  46.   files and other files that your program uses.
  47.  
  48.   For more discussion of Handle Tables and the implementation of
  49.   DOS redirection, please see Stan Mitchell, "Command Line
  50.   Redirection," PC Tech Journal, January 1986, Page 44.
  51.  
  52.   MODIFYING ACCESS.BOX:
  53.  
  54.   Check the comment header at the beginning of the file to ensure
  55.   you are using the correct ACCESS.BOX. Please BE SURE to make all
  56.   modifications on a backup copy of the ACCESS.BOX file.
  57.  
  58.   NOTE: If you have modified ACCESS.BOX per FLUSH.ACC, make the
  59.   following additional changes:
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Turbo Database Toolbox                 NUMBER  :  173
  75.   VERSION  :  1.01
  76.        OS  :  PC DOS
  77.      DATE  :  May 14, 1986                             PAGE  :  2/5
  78.  
  79.     TITLE  :  Files Open Increase
  80.  
  81.  
  82.  
  83.  
  84.   1. In FlushFile:
  85.   ----------------
  86.  
  87.   Add the following line immediately BEFORE the "Seek(...);"
  88.   statement:
  89.     UnExtend(DatF.F);
  90.  
  91.   Add the following line immediately after the FIRST "MsDos(...);"
  92.   statement:
  93.     ReExtend(DatF.F);
  94.  
  95.  
  96.   2. In FlushIndex:
  97.   -----------------
  98.  
  99.   Add the following line immediately BEFORE the "Seek(...);"
  100.   statement:
  101.     UnExtend(IdxF.DataF.F);
  102.  
  103.   Add the following line immediately after the "BlockWrite(..);"
  104.   statement:
  105.     ReExtend(IdxF.DataF.F);
  106.  
  107.   Type the following text into a separate file called EXTEND.PAS
  108.   and make sure that it is on your main program disk when you run
  109.   your program.
  110.  
  111.   {$F252}
  112.  
  113.   const
  114.    LastHandle = 19;    {Highest-numbered handle}
  115.    UnusedHandle = $FF; {DcbTable entry that denotes an unused
  116.   handle}
  117.   type
  118.     HandleTable = array[0..LastHandle] of Byte;
  119.     HandleTablePtr = ^HandleTable;
  120.   const
  121.     TablePtrOk: Boolean = false; {"True" if TablePtr is
  122.                                   initialized}
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Turbo Database Toolbox                 NUMBER  :  173
  141.   VERSION  :  1.01
  142.        OS  :  PC DOS
  143.      DATE  :  May 14, 1986                             PAGE  :  3/5
  144.  
  145.     TITLE  :  Files Open Increase
  146.  
  147.  
  148.  
  149.  
  150.   var
  151.     TablePtr: HandleTablePtr; {Points to Handle Table for this
  152.                                process}
  153.     SaveDcb:  Byte;  {Temporary variable for a DCB number during a
  154.   function call}
  155.  
  156.   {Internal  routine.   Returns  the address of the  Handle  Table,
  157.   which is at offset 18H in the PSP.}
  158.  
  159.   function GetHandleTableAddr: HandleTablePtr;
  160.   var
  161.     regs: record
  162.                   case Integer of
  163.             1: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags:
  164.   Integer);
  165.             2: (AL, AH, BL, BH, CL, CH, DL, DH: Byte) end;
  166.   begin
  167.     regs.AH := $30;
  168.     MsDos(regs);      {Get DOS version number}
  169.     case regs.AL of
  170.       0: begin
  171.                   writeln('This program only works with DOS 2.0 and
  172.   higher');
  173.                   Halt
  174.             end;
  175.       2: regs.AH := $51; {Undocumented, but works with}
  176.                              {DOS 2.0/2.1 (and 3.X)}
  177.     else regs.AH := $62  {Works with DOS 3.0 and higher}
  178.     end;
  179.     MsDos(regs);      {Get PSP address}
  180.     GetHandleTableAddr := Ptr(regs.BX, $18)
  181.   end {GetHandleTableAddr};
  182.  
  183.   {Causes "f" to become an "extended" file; i.e., to remain open
  184.   without using up any file handles. The parameter "f" must be any
  185.   Turbo Pascal file; e.g., a File, a File of Byte, a File of Foo,
  186.   Text, etc. This routine should be called immediately after the
  187.   Reset or Rewrite initially used to open "f." After "f" has become
  188.   extended, it cannot be used by Turbo's built-in file routines
  189.   until it has been unextended using UnExtend.}
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.   PRODUCT  :  Turbo Database Toolbox                 NUMBER  :  173
  207.   VERSION  :  1.01
  208.        OS  :  PC DOS
  209.      DATE  :  May 14, 1986                             PAGE  :  4/5
  210.  
  211.     TITLE  :  Files Open Increase
  212.  
  213.  
  214.  
  215.  
  216.   procedure OpenExtend (var f);
  217.   var
  218.     handle: Integer absolute f;
  219.   begin
  220.     if not TablePtrOk then
  221.       begin
  222.            TablePtr := GetHandleTableAddr;
  223.            TablePtrOk := true
  224.       end;
  225.     SaveDcb := TablePtr^[handle];
  226.     TablePtr^[handle] := UnusedHandle;
  227.     handle := SaveDcb
  228.   end {OpenExtend};
  229.  
  230.   {Unextends the extended file "f," so that it can be used by any
  231.   of  Turbo Pascal's built-in file routines. Note that "f" must
  232.   have  been converted to an extended file by OpenExtend before
  233.   invoking UnExtend(f). After calling UnExtend, and then invoking
  234.   the Turbo  Pascal file function on "f," ReExtend(f) should be
  235.   invoked  immediately to re-extend "f" and restore the DOS file
  236.   state information.}
  237.  
  238.   procedure UnExtend (var f);
  239.   var
  240.     handle: Integer absolute f;
  241.   begin
  242.     SaveDcb := TablePtr^[LastHandle];
  243.     TablePtr^[LastHandle] := Lo(handle);
  244.     handle := LastHandle
  245.   end {UnExtend};
  246.  
  247.  
  248.   {Re-extends "f" into an extended file. Note that "f" must have
  249.   been converted to an extended file by OpenExtend, and then
  250.   unextended using UnExtend, before "f" can be re-extended using
  251.   ReExtend. ReExtend(f) should be invoked immediately after any
  252.   normal Turbo Pascal file function call using "f."}
  253.  
  254.   procedure ReExtend (var f);
  255.   var
  256.     handle: Integer absolute f;
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.   PRODUCT  :  Turbo Database Toolbox                 NUMBER  :  173
  273.   VERSION  :  1.01
  274.        OS  :  PC DOS
  275.      DATE  :  May 14, 1986                             PAGE  :  5/5
  276.  
  277.     TITLE  :  Files Open Increase
  278.  
  279.  
  280.  
  281.  
  282.   begin
  283.     handle := TablePtr^[LastHandle];
  284.     TablePtr^[LastHandle] := SaveDcb
  285.   end {ReExtend};
  286.  
  287.  
  288.   TO USE THIS TECHNIQUE:
  289.  
  290.   Make the above modifications.  Then --
  291.  
  292.   At the top of your program, prior to the "program" statement, put
  293.   the  compiler directive {$F252}. (You may use a value smaller
  294.   than 252 if you wish. Under DOS 2.0/2.1, values above 96 have no
  295.   additional benefit. Each larger value for the {$F} directive uses
  296.   2 additional bytes in the program's global data space.) The value
  297.   you specify for the {$F} directive is the maximum number of files
  298.   you  will be able to have open at the same time in your program.
  299.  
  300.   In your program, PRIOR to the {$I ACCESS.BOX} (or {$I
  301.   ACCESS3.BOX}), insert a line that says {$I EXTEND.PAS}, to
  302.   include the EXTEND.PAS file listed above.
  303.  
  304.   Edit your CONFIG.SYS file (see the DOS manual for details) so
  305.   that it includes a line that says "FILES=XXX". XXX should be a
  306.   number that is 3 greater than the value you specified for the
  307.   {$F} directive (larger values will provide no additional benefit
  308.   with respect to your individual program), and should not exceed
  309.   99 (for DOS 2.0/2.1) or 255 (for DOS 3.0 and higher). Under any
  310.   version of DOS, the minimum allowable value for XXX is 8. Then,
  311.   reboot your computer so that the FILES=XXX parameter takes hold.
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.